#include<bits/stdc++.h>
using namespace std;
const int N=200005;
inline int read(){
    int k=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        if(ch=='-') f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        k=k*10+ch-'0';
        ch=getchar();
    }
    return k*f;
}
int t,n,d[N],v[N],a[N],m,l,o,p;
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    scanf("%d",&t);
    while(t--){
        scanf("%d%d%d%d",&n,&m,&l,&o);
        for(int i=1;i<=n;++i){
            scanf("%d%d%d",&d[i],&v[i],&a[i]);
        }
        for(int i=1;i<=m;++i){
            scanf("%d",&p);
        }
        printf("0 0");
        cout<<endl;
    }
    return 0;
}
